package com.cinema.model;

import java.time.LocalDateTime;
import java.util.Objects;

/**
 * 系统日志类
 * 
 * @author Cinema Management System
 * @version 1.0.0
 */
public class Log {
    
    /**
     * 日志ID
     */
    private String logId;
    
    /**
     * 操作时间
     */
    private LocalDateTime operationTime;
    
    /**
     * 操作类型
     */
    private String operationType;
    
    /**
     * 操作人
     */
    private String operator;
    
    /**
     * 操作详情
     */
    private String details;
    
    /**
     * 操作结果
     */
    private String result;
    
    /**
     * 默认构造函数
     */
    public Log() {
        this.operationTime = LocalDateTime.now();
    }
    
    /**
     * 构造函数
     * 
     * @param operationType 操作类型
     * @param operator 操作人
     * @param details 操作详情
     */
    public Log(String operationType, String operator, String details) {
        this();
        this.operationType = operationType;
        this.operator = operator;
        this.details = details;
        this.result = "成功";
    }
    
    /**
     * 构造函数
     * 
     * @param operationType 操作类型
     * @param operator 操作人
     * @param details 操作详情
     * @param result 操作结果
     */
    public Log(String operationType, String operator, String details, String result) {
        this(operationType, operator, details);
        this.result = result;
    }
    
    /**
     * 生成日志ID
     * 
     * @return 日志ID
     */
    private String generateLogId() {
        return "L" + System.currentTimeMillis() + "_" + (int)(Math.random() * 1000);
    }
    
    // Getter和Setter方法
    public String getLogId() {
        return logId;
    }
    
    public void setLogId(String logId) {
        this.logId = logId;
    }
    
    public LocalDateTime getOperationTime() {
        return operationTime;
    }
    
    public void setOperationTime(LocalDateTime operationTime) {
        this.operationTime = operationTime;
    }
    
    public String getOperationType() {
        return operationType;
    }
    
    public void setOperationType(String operationType) {
        this.operationType = operationType;
    }
    
    public String getOperator() {
        return operator;
    }
    
    public void setOperator(String operator) {
        this.operator = operator;
    }
    
    public String getDetails() {
        return details;
    }
    
    public void setDetails(String details) {
        this.details = details;
    }
    
    public String getResult() {
        return result;
    }
    
    public void setResult(String result) {
        this.result = result;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null || getClass() != obj.getClass()) return false;
        Log log = (Log) obj;
        return Objects.equals(logId, log.logId);
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(logId);
    }
    
    @Override
    public String toString() {
        return "Log{" +
                "logId='" + logId + '\'' +
                ", operationTime=" + operationTime +
                ", operationType='" + operationType + '\'' +
                ", operator='" + operator + '\'' +
                ", details='" + details + '\'' +
                ", result='" + result + '\'' +
                '}';
    }
} 